function modifyPwd(type){
	document.getElementById("pwdType").value=type;
	if(type == 0){
		document.getElementById("messageType").value = 12;
		document.getElementById("pwdTitle").innerHTML=passwordjs1;
		document.getElementById("originPwdTitle").innerHTML=passwordjs2;
		document.getElementById("newPwdTitle").innerHTML=passwordjs3;
		document.getElementById("reNewTitle").innerHTML=passwordjs4;
		document.getElementById("originPwdLi").style.display="";
		document.getElementById("tradePwdTips").style.display="none"; 
	}else if(type == 1){
		if(document.getElementById("isEmptyPhone") !=null && document.getElementById("isEmptyPhone").value==1&&document.getElementById("isEmptyAuth") !=null && document.getElementById("isEmptyAuth").value==1){
			bindAuth();
			return;
		}
		document.getElementById("messageType").value = 4;
		document.getElementById("pwdTitle").innerHTML=passwordjs5;
		document.getElementById("originPwdTitle").innerHTML=passwordjs6;
		document.getElementById("newPwdTitle").innerHTML=passwordjs7;
		document.getElementById("reNewTitle").innerHTML=passwordjs4;
		document.getElementById("tradePwdTips").style.display="";
		document.getElementById("originPwdLi").style.display="";
		if(document.getElementById("totpCode") !=null){
			document.getElementById("totpCode").value="";
		}
		if(document.getElementById("phoneCode") !=null){
			document.getElementById("phoneCode").value="";
		}
	}else{
		document.getElementById("messageType").value = 4;
		document.getElementById("pwdTitle").innerHTML=get$("passwordjs21");
		document.getElementById("newPwdTitle").innerHTML=passwordjs7;
		document.getElementById("reNewTitle").innerHTML=passwordjs8;
		document.getElementById("originPwdLi").style.display="none";
		document.getElementById("tradePwdTips").style.display="none";
	}
	if(document.getElementById("tradePwdTotpCode") !=null){
		document.getElementById("tradePwdTotpCode").value="";
	}
	if(document.getElementById("tradePwdPhoneCode") !=null){
		document.getElementById("tradePwdPhoneCode").value="";
	}
	if(document.getElementById("totpCodeTips") !=null){
		document.getElementById("totpCodeTips").innerHTMl="";
	}
	if(document.getElementById("phoneCodeTips") !=null){
		document.getElementById("phoneCodeTips").innerHTMl="";
	}
	document.getElementById("originPwd").value="";
	document.getElementById("newPwd").value="";
	document.getElementById("reNewPwd").value="";
	document.getElementById("originPwdTips").innerHTML="";
	document.getElementById("newPwdTips").innerHTML="";
	document.getElementById("reNewPwdTips").innerHTML="";
	dialogBoxShadow();
	document.getElementById("modifyPwd").style.display="";
	document.getElementById("newPwd").focus();
}
function sendPassWordMsgCode(){
	var type = document.getElementById("messageType").value;
	var isInter = document.getElementById("isInter").value;
	if(isInter==0){
		var msgType = document.getElementById("msgCodeBtnSign").value;
		if(msgType==1){
			document.getElementById("msgCodeBtn").disabled = true;
			inputDisabledTrue("msgCodeBtn");
			 for(var num=1;num<=secs;num++) {
				  window.setTimeout("updateNumberRestPwd(" + num + ")", num * 1000);
			  }
		}
		sendMsgCode1(type,msgType);
	}else{
		sendMsgCode(type);
	}
	
	//sendMsgCode(type);
}
function closePwd(perType){
	dialogBoxHidden();
	if(document.getElementById("modifyPwd")!=null){
		document.getElementById("modifyPwd").style.display="none";
	}
	//安全中心共用层
	if(document.getElementById("securityLayer")!=null){
		document.getElementById("securityLayer").style.display = "none";
		if(perType == 1){
			window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do?perType=1";
		}else{
			window.location.href= document.getElementById("coinMainUrl").value+"/user/security.do";
		}
	}

}
function submitPwdForm(perType){
	var pwdType = document.getElementById("pwdType").value;
	var originPwd = trim(document.getElementById("originPwd").value);
	var newPwd = trim(document.getElementById("newPwd").value);
	var reNewPwd = trim(document.getElementById("reNewPwd").value);
	
	var originPwdTips = isPassword(originPwd);
	var newPwdTips = isPassword(newPwd);
	var reNewPwdTips = isPassword(reNewPwd);
	
	if(pwdType < 2 && originPwdTips!=""){
		document.getElementById("originPwdTips").innerHTML="";
		document.getElementById("originPwdTips").innerHTML=originPwdTips;
		return;
	}else{
		document.getElementById("originPwdTips").innerHTML="";
	}
	 if( newPwdTips!=""){
		document.getElementById("newPwdTips").innerHTML="";
		document.getElementById("newPwdTips").innerHTML=newPwdTips;
		return;
	}else{
		document.getElementById("newPwdTips").innerHTML="";
	}
	if( reNewPwdTips!=""){
		document.getElementById("reNewPwdTips").innerHTML="";
		document.getElementById("reNewPwdTips").innerHTML=reNewPwdTips;
		return;
	}else if(newPwd != reNewPwd){
		document.getElementById("reNewPwdTips").innerHTML="";
		document.getElementById("reNewPwdTips").innerHTML=passwordjs9;
		document.getElementById("reNewPwd").value = "";
		return;
	}else{
		document.getElementById("reNewPwdTips").innerHTML="";
	}
	var  phoneCode = "";
	var totpCode = "";
	if(document.getElementById("tradePwdPhoneCode") != null){
		phoneCode = trim(document.getElementById("tradePwdPhoneCode").value);
		if(phoneCode == "" || phoneCode.length!=6){
			document.getElementById("phoneCodeTips").innerHTML=userindexjs4;
			return;
		}else{
			document.getElementById("phoneCodeTips").innerHTML="&nbsp;";
		}
	}
	if(document.getElementById("tradePwdTotpCode") != null){
		totpCode = trim(document.getElementById("tradePwdTotpCode").value);
		if(totpCode == "" || totpCode.length!=6){
			document.getElementById("totpCodeTips").innerHTML=userindexjs5;
			return;
		}else{
			document.getElementById("totpCodeTips").innerHTML="&nbsp;";
		}
	}
	if(document.getElementById("phoneCodeLi") == null && document.getElementById("totpCodeLi") == null){
		document.getElementById("messageSpan").innerHTML=passwordjs20;
		return;
	}
	var url = "/user/modifyPwd.do?random="+Math.round(Math.random()*100);
	var param={pwdType:pwdType,originPwd:originPwd,newPwd:newPwd,reNewPwd:reNewPwd,phoneCode:phoneCode,totpCode:totpCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode == 0){
				waitingStation("submitBtn",insubmiting);
				if(pwdType == 2 && document.getElementById("tradePwdSpan")!=null){
					document.getElementById("tradePwdSpan").innerHTML="<a  href='javascript:void(0);' onclick='javascript:modifyPwd(1);'>"+passwordjs11+"</a>";
				}
				document.getElementById("originPwdTips").innerHTML="";
				document.getElementById("newPwdTips").innerHTML="";
				document.getElementById("reNewPwdTips").innerHTML="";
				closePwd(perType);
				if(pwdType == 2){
					document.getElementById("modifyResultTips").innerHTML=passwordjs12;
				}else{
					document.getElementById("modifyResultTips").innerHTML=passwordjs13;
				}
				setTimeout(function(){document.getElementById("modifyResultTips").innerHTML="";}, 3000); 
			}else if(result.resultCode == -1){
				document.getElementById("messageSpan").innerHTML=rechargeusdsubfailure;
			 }else if(result.resultCode == -2){
				document.getElementById("newPwdTips").innerHTML=passwordjs14;
			 }else if(result.resultCode == -3){
				 document.getElementById("reNewPwdTips").innerHTML=passwordjs9;
				 document.getElementById("reNewPwd").value = "";
			 }else if(result.resultCode == -4){
				 document.getElementById("originPwdTips").innerHTML=coincommonjs35;
			 }else if(result.resultCode == -5){
				 document.getElementById("originPwdTips").innerHTML=passwordjs15;
				 document.getElementById("originPwd").value = "";
			 }else if(result.resultCode == -6){
				 if(result.errorNum == 0){
					 document.getElementById("totpCodeTips").innerHTML=exceededgooglecodeattempts;
				 }else{
					 document.getElementById("totpCodeTips").innerHTML=googlecodeincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("tradePwdTotpCode").value = "";
				 }
			 }else if(result.resultCode == -7){
				 document.getElementById("phoneCodeTips").innerHTML=smscodewrongmuchtime;
				 if(result.errorNum == 0){
				 }else{
					 document.getElementById("phoneCodeTips").innerHTML=smsisincorrect+youhave+result.errorNum+chancesleft;
					 document.getElementById("tradePwdPhoneCode").value = "";
				 }
			 }else if(result.resultCode == -8){
				 document.getElementById("phoneCodeTips").innerHTML=passwordjs17;
			 }else if(result.resultCode == -9){
				 document.getElementById("totpCodeTips").innerHTML=passwordjs16;
			}else if(result.resultCode == -10){
				if(pwdType == 0){
				   document.getElementById("newPwdTips").innerHTML=passwordjs18;
				}else if(pwdType == 1 || pwdType == 2){
					document.getElementById("newPwdTips").innerHTML=passwordjs19;
				}
			}else if(result.resultCode == -13){
				document.getElementById("messageSpan").innerHTML=passwordjs20;
			}else if(result.resultCode == -20){
				 document.getElementById("totpCodeTips").innerHTML=googlecodebeenused;
			 }
			
		}
	});
	

}

function isPassword(pwd){
	var desc = "";
	if(pwd == ""){
		desc=coincommonjs35;
	}else if(pwd.length <6){
		desc=coincommonjs12;
	}else if(pwd.length>32){
		desc=coincommonjs36;
	}
	return desc;
}
